#pragma once
#include <Windows.h>
#include "string/mstring.h"

class CShareMemoryOperator {
public:
    CShareMemoryOperator();
    virtual ~CShareMemoryOperator();

    bool Create(const std::mstring &name, unsigned int size, bool bLowSec = true);
    bool Open(const std::mstring &name);
    bool IsOpened() const;
    bool Flush(const char *ptr, unsigned int size);
    void Close();

    unsigned int GetSize() const;
    char *GetData(unsigned int offset, unsigned int size);

private:
    bool mIsOpened;
    HANDLE mhMapFile;
    char *mBuffer;
    std::mstring mName;
    unsigned int mBuffSize;
};